home *** CD-ROM | disk | FTP | other *** search
/ More MacCube 1: Arcade Games / More MacCube Vol 1 Arcade Games.bin / Games⁄Arcade / Bolo / More information / Sample Code / Std Autopilot / Brain.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  6.9 KB  |  241 lines  |  [TEXT/KAHL]

  1. #ifdef __powerc
  2. #pragma options align=mac68k
  3. #endif
  4.  
  5. #define local static
  6. #define export
  7. #define import extern
  8.  
  9. typedef unsigned char  u_char;
  10. typedef unsigned short u_short;
  11. typedef unsigned long  u_long;
  12.  
  13. typedef u_char  NIBBLE;    // to be interpreted as four bits
  14. typedef u_char  BYTE;
  15. typedef u_short WORD;
  16. typedef struct { u_char c[36]; } u_char36;
  17.  
  18. typedef BYTE MAP_X,   MAP_Y;
  19. typedef WORD WORLD_X, WORLD_Y;
  20.  
  21. // The various accessible tank control functions
  22. enum
  23.     {
  24.     KEY_faster=0, KEY_slower, KEY_turnleft, KEY_turnright,
  25.     KEY_morerange, KEY_lessrange, KEY_shoot, KEY_dropmine,
  26.     KEY_TankView, KEY_PillView
  27.     };
  28. #define setkey(CONTROLVECTOR, COMMAND) CONTROLVECTOR |= (1<<COMMAND)
  29. #define testkey(CONTROLVECTOR, COMMAND) ((CONTROLVECTOR & (1<<COMMAND)) != 0)
  30.  
  31. typedef BYTE TERRAIN;
  32. enum
  33.     {
  34.     BUILDING=0, RIVER, SWAMP, CRATER, ROAD, FOREST, RUBBLE, GRASS,
  35.     HALFBUILDING, BOAT, DEEPSEA, REFBASE_T, PILLBOX_T,
  36.     TERRAIN_UNKNOWN,
  37.     NUM_TERRAINS,
  38.     TERRAIN_MASK     = 0x0F,
  39.     TERRAIN_TANK_VIS = 0x10,
  40.     TERRAIN_PILL_VIS = 0x20,
  41.     TERRAIN_UNUSED   = 0x40,
  42.     TERRAIN_MINE     = 0x80
  43.     };
  44.  
  45. #define is_wet(A) ((A) == RIVER || (A) == BOAT || (A) == DEEPSEA)
  46.  
  47. typedef BYTE BUILDMODE;
  48. enum
  49.     {
  50.     BUILDMODE_FARM=1, BUILDMODE_ROAD,
  51.     BUILDMODE_BUILD, BUILDMODE_PBOX, BUILDMODE_MINE
  52.     };
  53.  
  54. typedef struct
  55.     {
  56.     MAP_X x;
  57.     MAP_Y y;
  58.     BUILDMODE action;
  59.     } BuildInfo;
  60.  
  61. // Farming gets you 4 tree units.
  62. // Roads, bridges and buildings take 2 units, boats take 20
  63. // Placing a pillbox takes 4 units, repairing takes proportionately less
  64.  
  65. #define NEUTRAL_PLAYER 0xFF
  66. // player id used to identify neutral bases and pillboxes
  67. #define FORESTVISUAL 0x30
  68. #define MINRANGE 2
  69. #define MAXRANGE 14        // In HALF map-squares
  70. #define MAX_PILL_ARMOUR 15
  71. #define MAX_BASE_SHELLS 90
  72. #define MAX_BASE_MINES  90
  73. #define MAX_BASE_ARMOUR 90
  74. #define ARMOUR_COST 5
  75. #define BASE_RESIST_SHELLS (ARMOUR_COST)
  76. #define BASE_RESIST_TANKS (ARMOUR_COST*2)
  77. #define MIN_BASE_ARMOUR (BASE_RESIST_TANKS + ARMOUR_COST - 1)
  78. // A base bust have one armour unit or more to resist a shell --
  79. // otherwise it is 'transparent' to shells.
  80. // It must have two armour units to or more resist a tank.
  81. // This is so that, after shooting a base down to 'transparency',
  82. // there is some reasonble time window in which to drive onto it.
  83.  
  84. typedef u_long PlayerBitMap;
  85.  
  86. typedef struct { u_long machineid; u_long timestamp; } GAMEID;
  87.  
  88. enum { GameType_open=1, GameType_tournament, GameType_strict_tment };
  89.  
  90. #define GAMEINFO_HIDDENMINES 0x80
  91. #define GAMEINFO_ALLMINES_VISIBLE 0xC0
  92.  
  93. typedef struct
  94.     {
  95.     u_char36 mapname;
  96.     GAMEID gameid;
  97.     BYTE gametype;
  98.     BYTE hidden_mines;
  99.     // has the value GAMEINFO_HIDDENMINES or GAMEINFO_ALLMINES_VISIBLE
  100.     BYTE allow_AI;
  101.     BYTE assist_AI;
  102.     long start_delay;
  103.     long time_limit;
  104.     } GAMEINFO;
  105.  
  106. // *********************************************************************
  107.  
  108. typedef u_short OBJECT;
  109. enum
  110.     {
  111.     OBJECT_TANK=0,
  112.     OBJECT_SHOT,
  113.     OBJECT_PILLBOX,
  114.     OBJECT_REFBASE,
  115.     OBJECT_BUILDMAN,
  116.     OBJECT_PARACHUTE
  117.     };
  118.  
  119. #define OBJECT_HOSTILE 1    // Object is hostile to us
  120. #define OBJECT_NEUTRAL 2    // Object is not loyal to any other player
  121. // Note that being neutral means that an object has no particular loyalty
  122. // to any player -- whether it is hostile or friendly to us is an orthogonal
  123. // question. Currently, neutral refuelling bases are friendly to everyone
  124. // and neutral pillboxes are hostile to everyone.
  125.  
  126. typedef struct
  127.     {
  128.     OBJECT object;
  129.     WORLD_X x;
  130.     WORLD_Y y;
  131.     WORD idnum;
  132.     BYTE direction;
  133.     BYTE info;
  134.     } ObjectInfo;
  135.  
  136. // For pillboxes and refuelling bases, the 'direction' field
  137. // actually holds the armour strength
  138. #define pillbox_strength direction
  139. #define refbase_strength direction
  140.  
  141. typedef struct
  142.     {
  143.     u_short sender;
  144.     PlayerBitMap *receivers;
  145.     u_char *message;
  146.     } MessageInfo;
  147.  
  148. // This header file describes Bolo BrainInfo structure version 3
  149. #define CURRENT_BRAININFO_VERSION 3
  150.  
  151. enum { BRAIN_OPEN=0, BRAIN_CLOSE, BRAIN_THINK, BRAIN_MENU=200 };
  152.  
  153. typedef struct
  154.     {
  155.     u_short BoloVersion;    // two hex bytes, eg. 0x0098 means version 0.98
  156.     u_short InfoVersion;    // current version of the BrainInfo structure is 1
  157.     void   *userdata;        // Initially points to address of your CODE resource
  158.     u_short PrefsVRefNum;
  159.     u_char *PrefsFileName;
  160.     u_short operation;        // 0=OPEN, 1=CLOSE, 2=THINK, 200+ menu
  161.     u_short menu_item;
  162.  
  163.     // Interface providing information about the Bolo world
  164.     
  165.     u_short max_players;    // Players are numbered from 0 to max_players-1
  166.     u_short max_pillboxes;    // Pillboxes are numbered from 0 to max_pillboxes-1
  167.     u_short max_refbases;    // Bases are numbered from 0 to max_refbases-1
  168.     u_short player_number;    // Who Am I?
  169.     u_short num_players;    // How many players currently active in this game?
  170.     u_char36 **playernames;    // Array of pointers to pascal strings
  171.     PlayerBitMap *allies;    // Who you are currently allied to
  172.  
  173.     WORLD_X tankx;
  174.     WORLD_Y tanky;
  175.     
  176.     BYTE direction;
  177.     BYTE speed;                // 64 is top speed on road, 48 on grass,
  178.                             // 24 in forest, 12 on rubble, crater, water etc.
  179.     BYTE inboat;            // non-zero means currently on boat
  180.     BYTE hidden;            // non-zero means hidden inside forest
  181.  
  182.     BYTE shells;            // Range 0-40
  183.     BYTE mines;                // Range 0-40
  184.     BYTE armour;            // Range 0-8
  185.     BYTE trees;                // Range 0-40
  186.  
  187.     BYTE carriedpills;        // Number of pillboxes the tank is carrying
  188.     BYTE carriedbases;        // Number of refuelling bases (zero in current versions)
  189.     WORD padding2;
  190.  
  191.     BYTE gunrange;            // in units of half map squares
  192.     BYTE reload;            // non-zero means cannot fire shell immediately
  193.     BYTE newtank;            // Set initially, and each time tank is killed
  194.     BYTE tankobstructed;    // Set if tank has hit obstacle
  195.     
  196.     ObjectInfo *base;        // will be NULL if no friendly base nearby
  197.     BYTE base_shells;
  198.     BYTE base_mines;
  199.     BYTE base_armour;
  200.     BYTE padding3;            // unused at present
  201.  
  202.     BYTE man_status;        // 0 = in tank, 1 = dead, other = outside
  203.     BYTE man_direction;
  204.     WORLD_X man_x;
  205.     WORLD_Y man_y;
  206.     BYTE manobstructed;        // 0 = free, 1 = touching wall, 2 = completely stuck
  207.     BYTE padding4;            // unused at present
  208.  
  209.     WORD *pillview;            // top bit set (0x8000) means view is from tank
  210.     MAP_Y view_top;            // coordinate of topmost square of current view
  211.     MAP_X view_left;        // coordinate of leftmost square of current view
  212.     BYTE  view_height;        // height of the view, in map squares
  213.     BYTE  view_width;        // width of the view, in map squares
  214.     TERRAIN *viewdata;        // view_width*view_height bytes of terrain data
  215.  
  216.     WORD padding5;            // unused at present
  217.     u_short num_objects;    // number of moving objects visible
  218.     ObjectInfo *objects;    // array information about those objects
  219.  
  220.     MessageInfo *message;    // Set if you recevied a message
  221.  
  222.     // Interface to control the tank
  223.     u_long *holdkeys;
  224.     u_long *tapkeys;
  225.     BuildInfo *build;
  226.     PlayerBitMap *wantallies;// Who you want to be allied to
  227.     PlayerBitMap *messagedest;
  228.     u_char *sendmessage;
  229.     
  230.     // New additions for version 3
  231.     const TERRAIN *theWorld;// Pointer to 256x256 map squares (arranged in rows)
  232.     GAMEINFO gameinfo;        // The game options
  233.     
  234.     } BrainInfo;
  235.  
  236. typedef pascal short BoloBrain(const BrainInfo *braininfo);
  237.  
  238. #ifdef __powerc
  239. #pragma options align=reset
  240. #endif
  241.